<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <style>
        .outer{
            width: 200px;
            height: 200px;
            background-color: green;
        }
        .inner{
            width: 100px;
            height: 100px;
            background-color: yellow;
        }
    </style>
    <div class="outer">
        <div class="inner"></div>
    </div>
</body>
</html>
<script>
    document.querySelector('.outer').addEventListener('click',function(){
        console.log('outer');
    })

    document.querySelector('.inner').addEventListener('click',function(event){
        //事件冒泡：当标签存在嵌套时，内层标签事件触发后会自动触发外层标签的事件
        console.log('inner');
        //使用event对象阻止事件冒泡
        event.stopPropagation();
    })
</script>